<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8" isELIgnored="false"%>
<%@ include file="/WEB-INF/common/Head.jsp"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn"%>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<title></title>
<link rel="stylesheet" href="${resourceServer }/css/pintuer.css">
<link rel="stylesheet" href="${resourceServer }/css/admin.css">
<script src="${resourceServer }/js/jquery.js"></script>
<script src="${resourceServer }/js/pintuer.js"></script>
</head>

<body>

	<div class="panel admin-panel">
		<div class="panel-head">
			<strong class="icon-reorder">商品列表</strong>

		</div>
		<div class="padding border-bottom">
			<ul class="search" style="padding-left: 10px;">
				<li><button type="button" class="button border-yellow"
						onclick="window.location.href='${basepath}/product/add.do'">
						<span class="icon-plus-square-o"></span> 添加内容
					</button></li>
				<%-- <li>
						<form id="fm">
							<input type="text" placeholder="请输入搜索品牌名" name="name" class="input" style="width:250px; line-height:17px;display:inline-block" value="${brand.name }" />
							 &nbsp;&nbsp;是否有效
							<select name="isDel" class="input"   style="width:60px; line-height:17px;display:inline-block">
					            <option value="">全部</option>
					            
					            <option value="1" <c:if test="${brand.isDel==1 }">selected="selected"</c:if>>是</option>
					            <option value="0" <c:if test="${brand.isDel==0 }">selected="selected"</c:if>>否</option>
					          </select>
							<button href="javascript:void(0)" class="button border-main icon-search" > 搜索</button>
						</form>
					</li> --%>
			</ul>

		</div>
		<table class="table table-hover text-center">
			<thead>
				<tr>
					<th>编号</th>
					<th>图片</th>
					<th>名称</th>
					<th>品牌</th>
					<th>销售额</th>
					<th>上/下架</th>
					<th>操作</th>
				</tr>
			</thead>
			<tbody>
				<c:forEach items="${products }" var="product">
					<tr>
						<td class="proId">${product.id }</td>
						<%-- <td><img src="${imgServer }/${product.images}" alt=""
							width="100" height="50" /></td> --%>

						<td><img
							src='${imgServer}/${fn:split(product.images, ";")[0]}' alt=""
							width="100" height="50" /></td>

						<td>${product.name }</td>
						<td><c:forEach items="${brandsList }" var="brand">
								<c:if test="${brand.key eq product.brandId}">
						${brand.value}
						</c:if>
							</c:forEach></td>
						<td>${product.sales }</td>
						<td>
							<%-- <select id="sshow" name="is_show">
								<c:if test="${product.isShow == 1 }">
									<option class="isShow" value="1" selected>&nbsp&nbsp&nbsp是&nbsp&nbsp&nbsp</option>
									<option class="isShow" value="0">&nbsp&nbsp&nbsp否&nbsp&nbsp&nbsp</option>
								</c:if>
								<c:if test="${product.isShow == 0 }">
									<option class="isShow" value="1">&nbsp&nbsp&nbsp是&nbsp&nbsp&nbsp</option>
									<option class="isShow" value="0" selected>&nbsp&nbsp&nbsp否&nbsp&nbsp&nbsp</option>
								</c:if>
						</select> --%> 
						<a class="button border-main"
							href="javascript:void(0)" onclick="isShow(${product.id},${product.isShow })"><span
								class="icon-edit"></span> <c:if
									test="${product.isShow == 1 }">下架</c:if> <c:if
									test="${product.isShow == 0 }">上架</c:if> </a>
						</td>
						<td>
							<div class="button-group">
								<a class="button border-main"
									href="${basepath }/product/details.do?id=${product.id}"><span
									class="icon-edit"></span> 查看</a> <a class="button border-main"
									href="${basepath }/sku/list.do?productId=${product.id }"><span
									class="icon-edit"></span> sku</a> <a class="button border-main"
									href="edit.do?id=${product.id }"><span class="icon-edit"></span>修改</a>
								<a class="button border-red" href="javascript:void(0)"
									onclick="del(${product.id})"><span class="icon-trash-o"></span>删除</a>
							</div>
						</td>
					</tr>
				</c:forEach>
			</tbody>
		</table>
	</div>
	<script src="${resourceServer }/js/page.js"></script>
	<div id="pagelist" class="pagelist"></div>

	<script type="text/javascript">
			$(function(){
				 $("#pagelist").mypage({
					pageNo:"${product.pageNo}",
					params:"${product.params}",
					url:"${product.url}",
					totalPage:"${product.pages}"
				}); 
				 
				 
				 
				 
				 
			});		
			
			
			
			
			function del(id){
				if(confirm("是否要删除")){
					window.location.href="del.do?id="+id;
				}
			}
			 
			 function isShow(id,isShow){
				 
				 if( isShow== 1){
					 if(confirm("确定下架？")){
				 window.location.href="editIsShow.do?id="+id; 
						}
				 }else if(isShow == 0){
					 if(confirm("确定上架？")){
						 window.location.href="editIsShow.do?id="+id; 
								}
				 }
				 
			 }
		</script>
</body>
</html>